package org.sdsc.crms.entity.security;

import java.util.LinkedHashSet;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
/**
 * 角色
 * 
 * @author helin
 * 
 */
@Entity
@Table(name = "CRMS_ROLE")
public class Role {

	private Long id;
	private String name;
	private Set<User> users = new LinkedHashSet<User>();

	@Id
	@GeneratedValue(generator = "roleGenerator")
	@GenericGenerator(name = "roleGenerator", strategy = "sequence", parameters = { @Parameter(name = "sequence", value = "SEQ_ROLE") })
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@ManyToMany(mappedBy = "roles")
	public Set<User> getUsers() {
		return users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}

	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
}
